package com.ruoyi.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.PetCategoryMapper;
import com.ruoyi.system.domain.PetCategory;
import com.ruoyi.system.service.IPetCategoryService;
import com.ruoyi.common.core.text.Convert;

/**
 * 分类信息Service业务层处理
 * 
 * @author 李姝函
 * @date 2024-09-11
 */
@Service
public class PetCategoryServiceImpl extends ServiceImpl<PetCategoryMapper,PetCategory> implements IPetCategoryService

{
    @Autowired
    private PetCategoryMapper petCategoryMapper;

    /**
     * 查询分类信息
     * 
     * @param id 分类信息主键
     * @return 分类信息
     */
    @Override
    public PetCategory selectPetCategoryById(Long id)
    {
        return petCategoryMapper.selectPetCategoryById(id);
    }

    /**
     * 查询分类信息列表
     * 
     * @param petCategory 分类信息
     * @return 分类信息
     */
    @Override
    public List<PetCategory> selectPetCategoryList(PetCategory petCategory)
    {
        return petCategoryMapper.selectPetCategoryList(petCategory);
    }

    /**
     * 新增分类信息
     * 
     * @param petCategory 分类信息
     * @return 结果
     */
    @Override
    public int insertPetCategory(PetCategory petCategory)
    {
        SysUser sysUser = ShiroUtils.getSysUser();
        petCategory.setCreateBy(sysUser.getUserName());
        petCategory.setUpdateBy(sysUser.getUserName());
        petCategory.setCreateTime(DateUtils.getNowDate());
        return petCategoryMapper.insertPetCategory(petCategory);
    }

    /**
     * 修改分类信息
     * 
     * @param petCategory 分类信息
     * @return 结果
     */
    @Override
    public int updatePetCategory(PetCategory petCategory)
    {
        SysUser sysUser = ShiroUtils.getSysUser();
        petCategory.setUpdateBy(sysUser.getUserName());
        petCategory.setUpdateTime(DateUtils.getNowDate());
        return petCategoryMapper.updatePetCategory(petCategory);
    }

    /**
     * 批量删除分类信息
     * 
     * @param ids 需要删除的分类信息主键
     * @return 结果
     */
    @Override
    public int deletePetCategoryByIds(String ids)
    {
        return petCategoryMapper.deletePetCategoryByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除分类信息信息
     * 
     * @param id 分类信息主键
     * @return 结果
     */
    @Override
    public int deletePetCategoryById(Long id)
    {
        return petCategoryMapper.deletePetCategoryById(id);
    }
}
